package com.wyg.blog.controller.view_blog;

import com.wyg.blog.utils.IpAddress;
import com.wyg.blog.utils.JsonResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @description:
 * @author: WYG
 * @time: 2020/7/8 23:00
 */
@RestController
@RequestMapping("/api/IpAddress")
public class IpAddressController {

    @GetMapping("/getIpAddress")
    @CrossOrigin
    public JsonResult<String> getIpAddress(HttpServletRequest request){
        String ipAddress = IpAddress.getIpAddr(request);
        return new JsonResult<>(ipAddress,"200","获取IP地址成功!");
    }
}
